package com.sohu.tv.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sohu.tv.dao.UserDao;
import com.sohu.tv.entity.User;
import com.sohu.tv.entity.UserInfo;
import com.sohu.tv.service.UserService;

@Service
public class UserServiceImpl implements UserService{
	
	@Resource
	UserDao userDao;
	
	@Override
	public User queryById(int userId) {
		return userDao.getById(userId);
	}
	
	@Override
	@Transactional
	public int addOpenIdById(int userId, String openId) {
		return userDao.addOepnId(userId, openId);
	}


	@Override
	public User queryByUserPass(String username,String password) {
		User user = userDao.queryByUserName(username);
		if(user != null && password.equals(user.getPassword())){
			return user;
		}
		return null;
	}

	@Override
	public User queryByName(String username) {
		// TODO Auto-generated method stub
		return userDao.queryByUserName(username);
	}

	@Override
	public UserInfo queryByUserId(int userId) {
		// TODO Auto-generated method stub
		return userDao.queryByUserId(userId);
	}

}
